﻿using System;
using System.Collections.Generic;
using Export2Excel;
using Export2ExcelTest;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;

namespace ImporterTest
{
    [TestClass]
    public class ImporterTesting
    {
        [TestMethod]
        public void TestMethod1()
        {
            List<LevelModelBase> modelCollection = new List<LevelModelBase>();
            List<FixedAssetInfo> result = new List<FixedAssetInfo>();

            ExcelImporter importer = new ExcelImporter(@"Template\软件基础表.xlsx");
            importer.DataImport<FixedAssetInfo>
                (
                    "固定资产目录-国电集团",
                    new int[] { 3 },
                    () => { return new FixedAssetInfo(); },
                    model =>
                    {
                        result.Add(model);
                        modelCollection.Add(new FixedAssetLevelPresentation(model));
                    }
                );

            FixedAssetLevelPresentation.AnalyseLevelInfo(null, modelCollection, 5);
            modelCollection.Clear();

            Assert.IsTrue(result.First(p => p.Id == result.First(s => s.Name == "四块分离器").ParentId).Types == "（1）卸煤机械");
            Assert.IsTrue(result.First(p => p.Id == result.First(s => s.Name == "输煤机械").ParentId).Types == "    1．输煤设备");
            Assert.IsTrue(result.First(p => p.Id == result.First(s => s.Name == "煤粉设备").ParentId).Types == "（一）发电及供热设备");

            Assert.IsTrue(result.First(p => p.Id == result.First(s => s.Name == "锅炉辅机").ParentId).Types == "4．锅炉设备");
            Assert.IsTrue(result.First(p => p.Id == result.First(s => s.Name == "衡温衡湿机").ParentId).Types == "（十）生产管理用工器具");
        }
    }
}
